<script setup>
    import { ref } from 'vue'
    import { repGetReportService } from '@/api/report'
    import { subGetSubjectService } from '@/api/subject'

    // 后端获取的表格所需的数据
    const tableDate = ref([])

    const getReport = async() => {
        const { data } = await repGetReportService()
        tableDate.value = data.data
    }

    // 下拉框的数据
    const selectValue = ref()

   // 用来展示的科目分类
   const subject = ref([])

   const getSubject = async() => {
    const { data } = await subGetSubjectService()
    data.data.forEach(item => {
        subject.value.push(item.name)
    })
   }
   getSubject()

   // 接收父组件的数据
   const props = defineProps({
    subject: String
   })

   const drawerSubject = () => {
    selectValue.value = props.subject
   }

   const giveValue = () => {
    return selectValue.value
   }

    // 将下拉菜单的数据传给父组件
    defineExpose({
    selectValue,
    drawerSubject,
    giveValue
   })
</script>

<template>
        <el-select v-model="selectValue" placeholder="请选择科目">
            <el-option
            v-for="(item, index) in subject"
            :key="index"
            :label="item"
            :value="item"
            ></el-option>
        </el-select>
</template>

<style lang="scss" scoped>

</style>